<?php

declare(strict_types=1);

namespace App\Fastapp\Command;

use Hyperf\Command\Annotation\Command;
use Hyperf\Command\Command as HyperfCommand;
use Psr\Container\ContainerInterface;

#[Command]
class FastappClearCommand extends HyperfCommand
{
    public function __construct(protected ContainerInterface $container)
    {
        parent::__construct('fastapp:clear');
    }

    public function configure(): void
    {
        parent::configure();
        $this->setDescription('清除缓存数据');
    }

    public function handle(): void
    {
        api_cache()->clearCache();
        $u = redis()->keys('u*');
        if ($u) redis()->del($u);
    }
}
